/*
 * SFTPServerListener.h
 *
 *  Created on: Apr 6, 2011
 *      Author: sms103
 */

#ifndef SFTPSERVERLISTENER_H_
#define SFTPSERVERLISTENER_H_

class SFTPServerListener;

#include "SFTPServer.h"
#include "../networklib/TCPSocket.h"

#define DEFAULT_SERVER_LISTEN_PORT 55555

class SFTPServerListener {
public:
	SFTPServerListener(SFTPServer *server);

	bool isListening();
	void close();
	int getPort();

	virtual ~SFTPServerListener();

private:
	//keep a pointer to server to pass to new sessionhandlers
	SFTPServer *sftpServer;

	int serverListenPort;

	//our listening socket
	TCPSocket *listenSock;
	//sock is open and listening?
	bool listening;

	pthread_t listenerThread;
	string nsrootFile;
	string listenAddr;
	static void * runListenerThread(void *p);
	void setParams();

};

#endif /* SFTPSERVERLISTENER_H_ */
